<?php

use dosamigos\chartjs\Chart;
/* @var $this yii\web\View */

$this->title = '';
?>
<style>
    tr:hover{
        cursor:pointer;
        background-color: antiquewhite;
    }
    tr>td,th{
        padding-top: 0px !important;
        display: table-cell !important;
        vertical-align: middle !important;
        text-align: center !important;
    }
</style>
<div class="site-index">
    <div class="body-content">

        <div class="row">
            <div class="col-lg-12" style="background-color:rgb(187,211,249);padding: 10px; "><h4>订单处理信息</h4></div>
            <!--            发货提醒-->
            <div class="col-lg-4" style="background-color: white;border: 10px solid #bbdaff;text-align: center;padding-bottom: 5px;height: 400px;overflow: auto">
                <h3>发 货 提 醒</h3>
                <table class="table" style="border: 1px solid skyblue;">
                    <thead>
                    <th>订单号</th>
                    <th>用户姓名</th>
                    <th>用户头像</th>
                    <th>支付时间</th>
                    </thead>
                    <tbody>
                    <?php foreach($orderWarm as $k=>$v) {?>
                        <tr>
                            <td><a href="?r=orders%2Forderinfo%2Fupdate&id=<?=$v['order_id']?>"><?=$v['order_sn']?></a></td>
                            <td><?=$v['wx_name']?></td>
                            <td><img style="width: 60px;height: 60px;"  src="<?=$v['wx_images']?>"></td>
                            <td><?=date('Y-m-d H:s:i',$v['pay_time'])?></td>
                        </tr>
                    <?php }?>
                    </tbody>
                </table>
            </div>
            <!--            发货提醒-->

            <!--           发票提醒-->
            <div class="col-lg-4" style="background-color: white;border: 10px solid #bbdaff;text-align: center;padding-bottom: 5px;height: 400px;overflow: auto">
                <h3>发 票 提 醒</h3>
                <table class="table" style="border: 1px solid skyblue;">
                    <thead>
                    <th>订单号</th>
                    <th>用户姓名</th>
                    <th>用户头像</th>
                    <th>支付时间</th>
                    <th>处理操作</th>
                    </thead>
                    <tbody>
                    <?php foreach($invoice as $k=>$v) {?>
                        <tr>
                            <td><a href="?r=orders%2Forderinfo%2Fupdate&id=<?=$v['order_id']?>"><?=$v['order_sn']?></a></td>
                            <td><?=$v['wx_name']?></td>
                            <td><img style="width: 60px;height: 60px;"  src="<?=$v['wx_images']?>"></td>
                            <td><?=date('Y-m-d H:s:i',$v['pay_time'])?></td>
                            <td style="height: 120px;">
                                <button style="margin-bottom: 10px" class="btn btn-success" onclick="viewInvoice('<?=$v['invoice_id']?>')">查看</button>
                                <?php if($v['hav_buil']==0) { ?>
                                    <button class="btn btn-warning" onclick="dealInvoice('<?=$v['invoice_id']?>')">未处理</button>
                                <?php } else {?>
                                    <button class="btn btn-warning" onclick="dealInvoice('<?=$v['invoice_id']?>')">处理完成</button>
                                <?php }?>
                            </td>
                        </tr>
                    <?php }?>
                    </tbody>
                </table>
            </div>
            <!--            发票提醒-->

            <!--           付款 提醒-->
            <div class="col-lg-4" style="background-color: white;border: 10px solid #bbdaff;text-align: center;padding-bottom: 5px;height: 400px;overflow: auto">
                <h3>付 款 提 醒</h3>
                <table class="table" style="border: 1px solid skyblue;">
                    <thead>
                    <th>用户姓名</th>
                    <th>用户头像</th>
                    <th>操作</th>
                    </thead>
                    <tbody>
                    <?php foreach($shareRebARR as $k=>$v) {?>
                        <tr>
                            <td><?=$v['wx_name']?></td>
                            <td><img style="width: 60px;height: 60px;"  src="<?=$v['wx_images']?>"></td>
                            <td style="height: 120px;">
                                <a class="btn btn-success" href="?r=orders/ordergoods/rebdetail&wx_name=<?=$v['wx_name']?>&wx_images=<?=$v['wx_images']?>&share_reb_user_id=<?=$v['share_reb_user_id']?>">查看详情</a>
                            </td>
                        </tr>
                    <?php }?>
                    </tbody>
                </table>
            </div>
            <!--            发票提醒-->

            <!--            待发货订单-->
            <div class="col-lg-4" style="background-color: white;border: 10px solid #bbdaff;text-align: center;padding-bottom: 5px;height: 400px;overflow: auto">
                <h3>待发货订单</h3>

                <table class="table" style="border: 1px solid skyblue;">
                    <thead>
                    <th>订单号</th>
                    <th>用户姓名</th>
                    <th>用户头像</th>
                    <th>支付时间</th>
                    </thead>
                    <?php foreach($orderUnshipping as $k=>$v) {?>
                        <tr>
                            <td><a href="?r=orders%2Forderinfo%2Fupdate&id=<?=$v['order_id']?>"><?=$v['order_sn']?></a></td>
                            <td><?=$v['wx_name']?></td>
                            <td><img style="width: 60px;height: 60px;"  src="<?=$v['wx_images']?>"></td>
                            <td><?=date('Y-m-d H:s:i',$v['pay_time'])?></td>
                        </tr>
                    <?php }?>
                    <tbody>
                </table>
            </div>
            <!--            待发货订单-->
            <!--            售  后  单-->
            <div class="col-lg-4" style="background-color: white;border: 10px solid #bbdaff;text-align: center;padding-bottom: 5px;height: 400px;overflow: auto">
                <h3>售  后  单</h3>
                <table class="table" style="border: 1px solid skyblue;">
                    <thead>
                    <th>订单号</th>
                    <th>商品名称</th>
                    <th>商品图片</th>
                    <th>用户信息</th>
                    <th>处理状态</th>
                    </thead>
                    <tbody>
                    <?php foreach($cservice as $k=>$v) {?>
                        <tr onclick="view('<?=$v['cservice_id']?>')">
                            <td><?=$v['order_sn']?></td>
                            <td><?=$v['goods_name']?></td>
                            <td><img style="width: 60px;height: 60px;"  src="..<?=$v['goods_image']?>"></td>
                            <td><?=$v['wx_name']?></td>
                            <?php if($v['is_deal']==0) {?><td>等待处理</td><?php }?>
                            <?php if($v['is_deal']==1) {?><td>处理中</td><?php }?>
                            <?php if($v['is_deal']==2) {?><td>等待关闭</td><?php }?>
                            <?php if($v['is_deal']==3) {?><td>已关闭</td><?php }?>
                        </tr>
                    <?php }?>
                    </tbody>
                </table>
            </div>
            <!--            售  后  单-->

            <!--            用户处理信息-->
            <?php         if(in_array('Index@付款提醒',$newChildARR)) {?>
            <div class="col-lg-12" style="background-color:rgb(187,211,249);margin-top: 10px; "><h4>用户处理信息</h4></div>
            <div class="col-lg-12" style="background-color: white;border: 10px solid #bbdaff;text-align: center;padding-bottom: 5px;height: 400px;overflow: auto">
<!--                <h3>用户关注提醒</h3>-->
<!--                <table class="table" style="border: 1px solid skyblue;">-->
<!--                    <thead>-->
<!--                    <th>已关注未获取信息人数</th>-->
<!--                    <th>已支付未关注人数</th>-->
<!--                    <th>已关注人数</th>-->
<!--                    </thead>-->
<!--                    <tbody>-->
<!--                    <tr>-->
<!--                        <td>-->
<!--                            --><?//=$userCount2?><!--<br />-->
<!--                            <a class="btn btn-warning" href="?r=site%2Fsetinfo" >点击获取</a>-->
<!--                        </td>-->
<!--                        <td>-->
<!--                            --><?//=$userCount0?><!--<br />-->
<!--                            <a class="btn btn-success" href="?r=wxuser%2Findex" >查看</a>-->
<!--                        </td>-->
<!--                        <td>-->
<!--                            --><?//=$userCount1?><!--<br />-->
<!--                            <a class="btn btn-success" href="?r=wxuser%2Findex">查看</a>-->
<!--                        </td>-->
<!--                    </tr>-->
<!--                    </tbody>-->
<!--                </table>-->
                <?= Chart::widget([
                    'type' => 'Radar',
                    'options' => [
                        'height' => 400,
                    ],
                    'data' => [
                        'labels' => ["January", "February", "March", "April", "May", "June", "July"],
                        'datasets' => [
                            [
                                'fillColor' => "rgba(220,220,220,0.5)",
                                'strokeColor' => "rgba(220,220,220,1)",
                                'pointColor' => "rgba(220,220,220,1)",
                                'pointStrokeColor' => "#fff",
                                'data' => [65, 59, 90, 81, 56, 55, 40]
                            ],
                            [
                                'fillColor' => "rgba(151,187,205,0.5)",
                                'strokeColor' => "rgba(151,187,205,1)",
                                'pointColor' => "rgba(151,187,205,1)",
                                'pointStrokeColor' => "#fff",
                                'data' => [28, 48, 40, 19, 96, 27, 100]
                            ]
                        ]
                    ]
                ]);
                ?>
            </div>
             <?php  } ?>
            <!--            用户处理信息-->
        </div>
    </div>
</div>
<?= Chart::widget([
    'type' => 'Line',
    'options' => [
        'height' => 400,
        'width' => 900
    ],
    'data' => [
        'labels' => ["January", "February", "March", "April", "May", "June", "July"],
        'datasets' => [
            [
                'fillColor' => "rgba(220,220,220,0.5)",
                'strokeColor' => "rgba(220,220,220,1)",
                'pointColor' => "rgba(220,220,220,1)",
                'pointStrokeColor' => "#fff",
                'data' => [65, 59, 90, 81, 56, 55, 40]
            ],
            [
                'fillColor' => "rgba(151,187,205,0.5)",
                'strokeColor' => "rgba(151,187,205,1)",
                'pointColor' => "rgba(151,187,205,1)",
                'pointStrokeColor' => "#fff",
                'data' => [28, 48, 40, 19, 96, 27, 100]
            ]
        ]
    ]
]);
?>
<?= Chart::widget([
    'type' => 'Bar',
    'options' => [
        'height' => 400,
        'width' => 900
    ],
    'data' => [
        'labels' => ["January", "February", "March", "April", "May", "June", "July"],
        'datasets' => [
            [
                'fillColor' => "rgba(220,220,220,0.5)",
                'strokeColor' => "rgba(220,220,220,1)",
                'pointColor' => "rgba(220,220,220,1)",
                'pointStrokeColor' => "#fff",
                'data' => [65, 59, 90, 81, 56, 55, 40]
            ],
            [
                'fillColor' => "rgba(151,187,205,0.5)",
                'strokeColor' => "rgba(151,187,205,1)",
                'pointColor' => "rgba(151,187,205,1)",
                'pointStrokeColor' => "#fff",
                'data' => [28, 48, 40, 19, 96, 27, 100]
            ]
        ]
    ]
]);
?>
<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">

        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<script>
    var c_id='';
    //售后
    function view(cservice_id)
    {
        c_id = cservice_id;
        $('#myModal').modal({
            keyboard: true
        })

        $.ajax({
            url: '?r=site/cservice',
            type: 'post',
            data: {_csrf:'<?= Yii::$app->request->csrfToken ?>',cservice_id:cservice_id},
            success: function (data) {
                var mes = eval('('+data+')');
                if(mes[0]) {
                    var isDeal = mes['cservice'].is_deal;
                    var lin = (isDeal==0)?'checked':'';
                    var yi = (isDeal==1)?'checked':'';
                    var er = (isDeal==2)?'checked':'';
                    var san = (isDeal==3)?'checked':'';
                    var InputStr = "<input  style='margin-left: 20px;' name='dealradio' type='radio' value='0' "+lin+">等待处理" +
                        "<input  style='margin-left: 20px;'name='dealradio'  type='radio' value='1' "+yi+" >处理中" +
                        "<input style='margin-left: 20px;'name='dealradio'  type='radio' value='2' "+er+" >等待关闭" +
                        "<input  style='margin-left: 20px;'name='dealradio'  type='radio' value='3' "+san+" >关闭" ;

                    var content = mes['cservice'].content;

                    var csImg = mes['cservice_images'];
                    var num =  csImg.length;
                    var Imgdiv= '';
                    for(var i=0;i<num;i++) {
                        Imgdiv += "<img src='<?=Yii::$app->params['domurl']?>wx/frontend"+csImg[i].cservice_images+"' >";
                    }

                    var str = "<div style='border: solid 1px ghostwhite;padding: 5px;'><p>选择处理状态</p>" +
                    InputStr+
                    "</div>" +
                    "<div style='padding: 20px;border: solid 1px ghostwhite;'><p>用户售后内容：</p>" +
                    content +
                    "</div>" +
                    "<div>" +Imgdiv+
                    "</div>";

                    var htmlmod= '<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button><h4 class="modal-title" id="myModalLabel">对话框</h4></div>' +
                    '<div class="modal-body"></div>' +
                    str+
                    '<div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">关闭</button><button type="button" class="btn btn-primary" onclick="javascript:postTo()">提交</button></div>' ;

                    $(".modal-content").html (
                        htmlmod
                    );
                    $('input:radio[name="dealradio"]').change( function(){
                        $(this)[0].checked=true;
                    })
                }else{
                    alert(mes[1]);
                }
                return;
            }
        })
    }

    function postTo()
    {
        var dealradio = $('input[name=dealradio]');
        var num = 0;
        for(var i=0;i<dealradio.length;i++) {
            if(dealradio[i].checked==true){
                num = dealradio[i].value;
            }
        }
        $.ajax({
            url: '?r=site/cservicechange',
            type: 'post',
            data: {_csrf:'<?= Yii::$app->request->csrfToken ?>',cservice_id:c_id,num:num},
            success: function (data) {
                var mes = eval('('+data+')');
                if(mes[0]) {

                }else{
                    alert(mes[1]);
                }
                return;
            }
        })
    }

    //发票
    function viewInvoice(invoice_id)
    {
        c_id = invoice_id;
        $('#myModal').modal({
            keyboard: true
        })
        $.ajax({
            url: '?r=site/invoice',
            type: 'post',
            data: {_csrf:'<?= Yii::$app->request->csrfToken ?>',invoice_id:invoice_id},
            success: function (data) {
                var mes = eval('('+data+')');
                if(mes[0]) {
                    var invoice = mes['invoice'];
                    if(invoice.porc=="1"){
                        var str = "<table class='table'>" +
                            "<thead>" +
                                "<th>公司名称" +
                                "</th>"+
                                "<th>公司税号" +
                                "</th>"+
                                "<th>是否支付" +
                                "</th>"+
                                "<th>发票类型" +
                                "</th>"+
                            "</thead>"+
                            "<body>" +
                                "<tr>" +
                                    "<td>"+invoice.c_name +
                                    "</td>"+
                                    "<td>" +invoice.c_code +
                                    "</td>"+
                                    "<td>" +invoice.is_payed +
                                    "</td>"+
                                    "<td>" +invoice.invoice_type +
                                    "</td>"+
                                "</tr>"+
                            "</body>"+
                        "</table>"
                    }
                    $(".modal-content").html (str);
                    console.log(invoice);
                }else{
                    alert(mes[1]);
                }
                return;
            }
        })
    }

    function dealInvoice(invoice_id)
    {
        $.ajax({
            url: '?r=site/invoicechange',
            type: 'post',
            data: {_csrf:'<?= Yii::$app->request->csrfToken ?>',invoice_id:invoice_id},
            success: function (data) {
                var mes = eval('('+data+')');
                if(mes[0]) {
                }
            }
        });
    }

</script>
